﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="LabelWithTimedMsg.ascx.cs" Inherits="TeamTime.LabelWithTimedMsg" %>
<asp:Label ID="lbl" runat="server" CssClass="infoLabel" EnableViewState="false" ></asp:Label>
<asp:TextBox ID="txtCountSeconds" runat="server" style="display:none;"  Text="0"></asp:TextBox>
<script type="text/javascript" >
var secs
var timerID = null
var running = false
var delay = 1000

function Init(s)
{
    secs = s;  // Set the length of the timer
    Stop();
    Start();
}
function Stop()
{
    if(running){
        clearTimeout(timerID);
    }
    running = false;
}

function Start() {
    var l = document.getElementById('<%=lbl.ClientID %>');
    l.style.visibility = 'hidden';
    if (secs==0)
    {
        Stop()
        
        l.innerHTML = ''; //hide
        
    }
    else {
        l.style.visibility = 'visible';
        self.status = secs
        secs = secs - 1
        running = true
        timerID = self.setTimeout("Start()", delay)
    }
}
function pageLoad() {
    
    var t = document.getElementById('<%=txtCountSeconds.ClientID %>').value;
    //alert(t);
    if (t != '' && t != '0') {
        Init(parseInt(t));
    }
}
</script>